package ru.disa.blog.service;

import java.util.List;

import ru.disa.blog.comment.Comment;
import ru.disa.blog.post.Post;
import ru.disa.blog.post.PostId;
import ru.disa.blog.post.PostRepository;

public class BlogService {
	private PostRepository posts;
	public void setPostRepository(PostRepository posts) {
		this.posts = posts;
	}
	
	public Post post(String text) {
		Post post = new Post(text);
		this.posts.add(post);
		return post;
	}
	
	public Comment comment(PostId postId, String text) {
		Post post = this.posts.get(postId);
		return post.comment(text);		
	}
	
	public Post get(PostId postId) {
		return this.posts.get(postId);
	}
	
	public List<Post> getAll() {
		return this.posts.getAll();
	}
	
	public void delete(PostId postId) {
		this.posts.remove(postId);
	}
}
